package cc.autoapi.pucong.auto.flow.provider.log.controller;

import cc.autoapi.pucong.auto.flow.core.root.exception.AutoFlowBaseController;
import cc.autoapi.pucong.auto.flow.core.root.exception.AutoFlowExceptionHandler;
import cc.autoapi.pucong.auto.flow.core.root.utils.Res;
import cc.autoapi.pucong.auto.flow.provider.log.manager.ApiInstanceNodeManager;
import cc.autoapi.pucong.auto.flow.provider.log.entity.qo.ApiInstanceNodeQo;
import cc.autoapi.pucong.auto.flow.provider.log.entity.vo.ApiInstanceNodeDetailVo;
import cc.autoapi.pucong.auto.flow.provider.log.entity.vo.ApiInstanceNodeVo;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author pucong
 * @description 项目接口实例节点日志 controller
 * @create 2024-10-07
 */
@RestController
@Validated
@RequestMapping("/log/apiInstanceNode")
public class ApiInstanceNodeController extends AutoFlowBaseController implements AutoFlowExceptionHandler{

    @Resource
    private ApiInstanceNodeManager apiInstanceNodeManager;

    @GetMapping("/getList")
    public Res<List<ApiInstanceNodeVo>> getList(ApiInstanceNodeQo dto) {
        List<ApiInstanceNodeVo> apiInstanceNodeList = apiInstanceNodeManager.getList(dto);
        return Res.ok(apiInstanceNodeList);
    }

    @GetMapping("/getDetailById/{instancesId}/{apiNodeId}")
    public Res<ApiInstanceNodeDetailVo> getDetailById(@PathVariable("instancesId") String instancesId,
                                                      @PathVariable("apiNodeId") String apiNodeId) {
        ApiInstanceNodeDetailVo apiInstanceNodeDto = apiInstanceNodeManager.getDetailById(instancesId, apiNodeId);
        return Res.ok(apiInstanceNodeDto);
    }
}
